﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Barbar.MapReport.Common.Drawing.ValueIndicators;
using Barbar.MapReport.HtmlRender.Shapes;

namespace Barbar.MapReport.HtmlRender.Operations.ValueIndicators {
  internal class ValueIndicatorAgregatorBusinessRenderer : IValueIndicatorAgregatorRenderer {
    private BusinessProperties m_Properties;

    public ValueIndicatorAgregatorBusinessRenderer(BusinessProperties properties) {
      m_Properties = properties;
    }

    #region IValueIndicatorAgregatorRenderer Members

    public ShapeWithTooltip Render(ValueIndicatorAgregator agregator) {
      IShape shape = null;

      int realRadius = agregator.RealRadius;
      switch (m_Properties.CategoriesCount) {
        case 1: {
            Color color = Color.FromArgb(m_Properties.Descriptions[0].Color);
            shape = new CircleShape(realRadius, color);
            break;
          }
        case 2: {
            Color color0 = Color.FromArgb(m_Properties.Descriptions[0].Color);
            Color color1 = Color.FromArgb(m_Properties.Descriptions[1].Color);
            if (agregator.Items.Count == 1)
              shape = new DoubleCircleShape(realRadius, color0, color1);
            else
              shape = new DoubleCircleWithNumberShape(realRadius, color0, color1, agregator.Items.Count);
            break;
          }
        default:
          throw new NotImplementedException();
      }

      return new ShapeWithTooltip(shape, null);
    }

    #endregion
  }
}
